import * as dataTools from '@/utils/data.js';

const state = {
    OFeatureList: {
        chlora: [],
        current: [],
        wind: [],
        temp: [],
        salt: [],
        oceanheight: [],
        waveheight: [],
        hchlora: [],
        hsst: [],
        tide: [],
        oxygen: [],
        mlsp: []
    },

    OFDataTime: {
        chlora: '',
        current: '',
        wind: '',
        temp: '',
        salt: '',
        oceanheight: '',
        waveheight: '',
        hchlora: '',
        hsst: '',
        tide: '',
        oxygen: '',
        mlsp: ''
    },
    date: null,
}

const getters = {
}

const actions = {
    getmlsp(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'mlsp';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    getoxygen(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'oxygen';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    getchlora(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'chlora';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()           //获取时间轴叶绿素数据
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    getcurrent(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'current';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()           //获取时间轴洋流数据
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    getwind(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'wind';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()           //获取时间轴风速数据
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    gettemp(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'temp';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()           //获取时间轴温度数据
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    getsalt(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'salt';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()           //获取时间轴盐度数据
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    getoceanheight(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'oceanheight';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()           //获取时间轴海表高度数据
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    getwaveheight(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'waveheight';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()           //获取时间轴浪高数据
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    gethchlora(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'hchlora';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()           //获取时间轴葵花叶绿素数据
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    gethsst(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'hsst';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()           //获取时间轴葵花海温数据
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
    gettide(context, params) {
        const dates = params && params.dates ? params.dates : 4;
        const depth = params && params.depth ? params.depth : 0;
        const target = params && params.target ? params.target : 1;
        const type = params && params.type ? params.type : 'tide';
        const date = params && params.date ? params.date : null;
        const DataTools = new dataTools.DataNavigator()           //获取时间轴潮汐数据
        return DataTools.PostDataTime(dates, depth, target, type, date)
    },
}

const mutations = {
    GETCHLORA(state, value) {
        state.OFeatureList.chlora = [...value]
    },
    GETCURRENT(state, value) {
        state.OFeatureList.current = [...value]
    },
    GETWIND(state, value) {
        state.OFeatureList.wind = [...value]
    },
    GETTEMP(state, value) {
        state.OFeatureList.temp = [...value]
    },
    GETSALT(state, value) {
        state.OFeatureList.salt = [...value]
    },
    GETOCEANHEIGHT(state, value) {
        state.OFeatureList.oceanheight = [...value]
    },
    GETWAVEHEIGHT(state, value) {
        state.OFeatureList.waveheight = [...value]
    },
    GETHCHLORA(state, value) {
        state.OFeatureList.hchlora = [...value]
    },
    GETHSST(state, value) {
        state.OFeatureList.hsst = [...value]
    },
    GETTIDE(state, value) {
        state.OFeatureList.tide = [...value]
    },
    GETOXYGEN(state, value) {
        state.OFeatureList.oxygen = [...value]
    },
    GETMLSP(state, value) {
        state.OFeatureList.mlsp = [...value]
    },
    setDataTime(state, value) {
        state.OFDataTime[value.dataName] = value.dataTime;
    },
    updateDate(state, date) {
        state.date = date;
    }
}

export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations
}